/* SQLINES DEMO *** Dump SQL

 Source Server         : rongrong@192.168.1.228
 Source Server Type    : MySQL
 Source Server Version : 80035 (8.0.35)
 Source Host           : 192.168.1.228:3306
 Source Schema         : mytest

 Target Server Type    : MySQL
 Target Server Version : 80035 (8.0.35)
 File Encoding         : 65001

 Date: 02/11/2024 23:40:38
*/

/* SET NAMES utf8mb4; */
/* SET FOREIGN_KEY_CHECKS = 0; */

-- SQLINES DEMO *** -----------
-- SQLINES DEMO *** or course
-- SQLINES DEMO *** -----------
DROP TABLE IF EXISTS course;
-- SQLINES FOR EVALUATION USE ONLY (14 DAYS)
CREATE TABLE course (
  cno varchar(255) NOT NULL COMMENT '课程编号',
  cname varchar(255) NOT NULL COMMENT '课程名称',
  cpno varchar(255) DEFAULT NULL,
  ccredit varchar(255) DEFAULT NULL,
  PRIMARY KEY (cno)
) ;

-- SQLINES DEMO *** -----------
-- Re... SQLINES DEMO ***
-- SQLINES DEMO *** -----------
BEGIN;
INSERT INTO course (cno, cname, cpno, ccredit) VALUES ('C01', '高数', NULL, '6.5');
INSERT INTO course (cno, cname, cpno, ccredit) VALUES ('C02', 'C语言', 'CO1', '3.0');
INSERT INTO course (cno, cname, cpno, ccredit) VALUES ('C03', '数据结构', 'CO2', '3.5');
INSERT INTO course (cno, cname, cpno, ccredit) VALUES ('C04', '数据库', 'CO3', '3.5');
COMMIT;

-- SQLINES DEMO *** -----------
-- SQLINES DEMO *** or sc
-- SQLINES DEMO *** -----------
DROP TABLE IF EXISTS sc;
CREATE TABLE sc (
  sno varchar(255) NOT NULL,
  cno varchar(255) NOT NULL,
  grade int NOT NULL,
  PRIMARY KEY (sno,cno)
,
  CONSTRAINT FKEY_CNO FOREIGN KEY (cno) REFERENCES course (cno) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT FKEY_SNO FOREIGN KEY (sno) REFERENCES student (sno) ON DELETE CASCADE ON UPDATE CASCADE
) ;

CREATE INDEX FKEY_CNO ON sc (cno);

-- SQLINES DEMO *** -----------
-- Re... SQLINES DEMO ***
-- SQLINES DEMO *** -----------
BEGIN;
INSERT INTO sc (sno, cno, grade) VALUES ('20190001', 'C01', 95);
INSERT INTO sc (sno, cno, grade) VALUES ('20190001', 'C02', 85);
INSERT INTO sc (sno, cno, grade) VALUES ('20190001', 'C04', 73);
INSERT INTO sc (sno, cno, grade) VALUES ('20190002', 'C01', 70);
INSERT INTO sc (sno, cno, grade) VALUES ('20190002', 'C03', 100);
COMMIT;

-- SQLINES DEMO *** -----------
-- SQLINES DEMO *** or student
-- SQLINES DEMO *** -----------
DROP TABLE IF EXISTS student;
CREATE TABLE student (
  sno varchar(255) NOT NULL COMMENT '学生编号',
  sname varchar(255) NOT NULL COMMENT '学生名称',
  ssex varchar(255) NOT NULL COMMENT '性别',
  sage int NOT NULL COMMENT '年龄',
  sdept varchar(255) NOT NULL COMMENT '系别',
  PRIMARY KEY (sno),
  CONSTRAINT sage_check CHECK (((sage >= 14) and (sage <= 25)))
) ;

-- SQLINES DEMO *** -----------
-- Re... SQLINES DEMO ***
-- SQLINES DEMO *** -----------
BEGIN;
INSERT INTO student (sno, sname, ssex, sage, sdept) VALUES ('20190001', '张晓明', '男', 18, 'IS');
INSERT INTO student (sno, sname, ssex, sage, sdept) VALUES ('20190002', '李小海', '男', 19, 'IS');
INSERT INTO student (sno, sname, ssex, sage, sdept) VALUES ('20190003', '蔡芸', '女', 18, 'MA');
INSERT INTO student (sno, sname, ssex, sage, sdept) VALUES ('20190004', '毛小娟', '女', 19, 'PH');
INSERT INTO student (sno, sname, ssex, sage, sdept) VALUES ('20190005', '刘云云', '女', 18, 'IS');
INSERT INTO student (sno, sname, ssex, sage, sdept) VALUES ('20190006', '马骅', '女', 19, 'PH');
COMMIT;

/* SET FOREIGN_KEY_CHECKS = 1; */
